//
//  CAGoodsListCollectionViewCell.m
//  LNH
//
//  Created by twentylx on 2018/1/16.
//  Copyright © 2018年 twentylx. All rights reserved.
//

#import "CAGoodsListCollectionViewCell.h"

@implementation CAGoodsListCollectionViewCell

- (instancetype) initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        
        [self addSubview:self.goodsImageView];
        [self addSubview:self.bgView];
        [self.bgView addSubview:self.goodsTitleLabel];
        [self.bgView addSubview:self.priceLabel];
        [self.bgView addSubview:self.vipLabel];
        
        [_goodsImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.and.right.equalTo(self);
            make.top.equalTo(self);
            make.height.mas_equalTo(170);
        }];
        
        [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.and.right.equalTo(self);
            make.top.equalTo(self.goodsImageView.mas_bottom);
            make.bottom.equalTo(self);
        }];
        
        [_goodsTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.bgView).offset(10);
            make.top.equalTo(self.bgView).offset(15);
            make.right.equalTo(self.bgView).offset(-10);
        }];
        
        [_priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.bgView).offset(10);
            make.top.equalTo(self.goodsTitleLabel.mas_bottom).offset(5);
        }];
        
        [_vipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.bgView).offset(-10);
            make.bottom.equalTo(self.bgView).offset(-5);
        }];
    }
    return self;
}

#pragma mark get & set
- (UIImageView *) goodsImageView {
    if (!_goodsImageView) {
        _goodsImageView = [UIImageView new];
        _goodsImageView.image = LMImageNamed(@"goodsList");
        _goodsImageView.contentMode = UIViewContentModeScaleAspectFit;
    }
    return _goodsImageView;
}

- (UIView *) bgView {
    if (!_bgView) {
        _bgView = [UIView new];
        _bgView.backgroundColor =  RGBCOLOR(247, 247, 247);
    }
    return _bgView;
}

- (UILabel *) goodsTitleLabel {
    if (!_goodsTitleLabel) {
        _goodsTitleLabel = [UILabel new];
        _goodsTitleLabel.text = @"swarovski施华洛世奇 新款15512-9钻戒";
        _goodsTitleLabel.textColor = [UIColor blackColor];
        _goodsTitleLabel.font = [UIFont systemFontOfSize:16];
        _goodsTitleLabel.numberOfLines = 2;
        _goodsTitleLabel.lineBreakMode = NSLineBreakByCharWrapping;
    }
    return _goodsTitleLabel;
}

- (UILabel *) priceLabel {
    if (!_priceLabel) {
        _priceLabel = [UILabel new];
        _priceLabel.text = @"￥9800.00";
        _priceLabel.font = [UIFont systemFontOfSize:16];
        _priceLabel.textColor = [UIColor blackColor];
        _priceLabel.textAlignment = NSTextAlignmentLeft;
    }
    return _priceLabel;
}

- (UILabel *) vipLabel {
    if (!_vipLabel) {
        _vipLabel = [UILabel new];
        _vipLabel.text = @"VIP";
        _vipLabel.textColor = RGBCOLOR(207, 89, 38);
        _vipLabel.textAlignment = NSTextAlignmentRight;
        _vipLabel.font = [UIFont systemFontOfSize:16];
    }
    return _vipLabel;
}

@end
